@*
    For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
*@
@model Abc.Utils.CG_CodeGenerateConfig
@{
}

<div class="layui-row layui-col-space10">
	<div class="layui-collapse" lay-filter="test">
		<div class="layui-colla-item">
			<h2 class="layui-colla-title">代码生成说明</h2>
			<div class="layui-colla-content">
				<p>1.参考了下sqlsugar的WebFirst ，使用了部分其中的固定内容</p>
				<p>2.模板可编辑，内置模板可生成</p>
				<p>3. Application层的Dto,Mapper,Service 文件，Service默认包含服务和动态API，可以适当修改</p>
				<p>4. Controller层的控制器代码</p>
				<p>5. Views 页面的cshtml.cs 代码</p>
				<p>6. 生成代码使用的SqlSugar相关的逻辑来实现，暂不提供EF</p>
				<p>7. 代码模板在 Abc.Web.Mvc 项目中 CodeTemplate 目录下</p>
				<p>8. 生成的代码在 Abc.Web.Mvc 项目中 GenerateCode 目录下，此目录git已经忽略不会上传</p>
				<p> <a href="https://antaris.github.io/RazorEngine/index.html" target="_blank">RazorEngine 官方文档地址</a></p>
				<p> <a href="https://github.com/Antaris/RazorEngine" target="_blank">RazorEngine GitHub地址</a></p>
			</div>
		</div>

	</div>

	<form class="layui-form" action="">

		<div class="layui-bg-gray" style="padding: 30px;">
			<div class="layui-row layui-col-space15">
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-header">基本信息</div>
						<div class="layui-card-body">
							<table class="layui-table">
								<colgroup>
									<col width="150">
									<col>
									<col width="200">
								</colgroup>
								<tbody>
									<tr>
										<td>项目名称</td>
										<td><input type="text" asp-for="ProjectName" required lay-verify="required" placeholder="" autocomplete="off" class="layui-input"></td>
										<td></td>
									</tr>
									<tr>
										<td>数据库-类型</td>
										<td>
											<select asp-for="DbType" asp-items="Html.GetEnumSelectList<SqlSugar.DbType>()"></select>
										</td>
										<td>使用的sqlsugar，更方便定制。。。</td>
									</tr>
									<tr>
										<td>数据库-连接字符串</td>
										<td><input type="text" class="layui-input" asp-for="DbConn" style="width:100%;" /></td>
										<td>为空表示，使用本项目数据库配置文件的第一个数据库去连接</td>
									</tr>
									<tr>
										<td>
											<div class="layui-btn submitbtn" lay-submit lay-filter="submit">保存配置</div>
										</td>
										<td>
											<div class="layui-btn submitbtn" lay-submit lay-filter="submit_gc">生成代码</div>
										</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-header">DB</div>
						<div class="layui-card-body">
							<table class="layui-table">
								<colgroup>
									<col width="150">
									<col>
									<col width="200">
								</colgroup>
								<tbody>
									<tr>
										<td>实体表前缀替换</td>
										<td><input type="text" class="layui-input" asp-for="DbTablePrefixReplace" style="width:100%;" /></td>
										<td></td>
									</tr>
									<tr>
										<td>实体表名字符串替，</td>
										<td><input type="text" class="layui-input" asp-for="DbTableReplace" style="width:100%;" /></td>
										<td>多个用英文逗号隔开，需要有=才能生效</td>
									</tr>
									<tr>
										<td>实体表名去前缀</td>
										<td><input type="text" class="layui-input" asp-for="DbTableNoPrefix" style="width:100%;" /></td>
										<td>多个前缀用英文逗号隔开</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-header">应用层</div>
						<div class="layui-card-body">
							<table class="layui-table">
								<colgroup>
									<col width="150">
									<col>
									<col width="200">
								</colgroup>
								<tbody>
									<tr>
										<td>区域（MVC）</td>
										<td><input type="text" class="layui-input" asp-for="MvcApplicationArea" style="width:100%;" /></td>
										<td></td>
									</tr>
									<tr>
										<td>服务层实体替换</td>
										<td><input type="text" class="layui-input" asp-for="ApplicationEntityReplace" style="width:100%;" /></td>
										<td>例如：Sys_=Ht,APC_=Ht或者Sys_=Ht,APC_=Ht，需要有=才能生效</td>
									</tr>
									<tr>
										<td>应用层Dto实体前缀（MVC）</td>
										<td><input type="text" class="layui-input" asp-for="MvcApplicationDtoPrefix" style="width:100%;" /></td>
										<td></td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-header">控制器Controller（MVC）</div>
						<div class="layui-card-body">
							<table class="layui-table">
								<colgroup>
									<col width="150">
									<col>
									<col width="200">
								</colgroup>
								<tbody>
									<tr>
										<td>控制器 命名空间</td>
										<td><input type="text" class="layui-input" asp-for="MvcControllerNameSpaceName" style="width:100%;" /></td>
										<td></td>
									</tr>
									<tr>
										<td>继承的基础类库</td>
										<td><input type="text" class="layui-input" asp-for="MvcControllerBaseName" style="width:100%;" /></td>
										<td></td>
									</tr>
									<tr>
										<td>区域</td>
										<td><input type="text" class="layui-input" asp-for="MvcControllerBaseName" style="width:100%;" /></td>
										<td></td>
									</tr>
									<tr>
										<td>控制器实体替换</td>
										<td><input type="text" class="layui-input" asp-for="MvcControllerEntityReplace" style="width:100%;" /></td>
										<td>等号前是被替换名称，等号后是替换的新内容，需要有=才能生效</td>
									</tr>
									<tr>
										<td>控制器实体前缀</td>
										<td><input type="text" class="layui-input" asp-for="MvcControllerEntityPrefix" style="width:100%;" /></td>
										<td></td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
				<div class="layui-col-md12">
					<div class="layui-card">
						<div class="layui-card-header">API</div>
						<div class="layui-card-body">
							<table class="layui-table">
								<colgroup>
									<col width="150">
									<col>
									<col width="200">
								</colgroup>
								<tbody>
									<tr>
										<td>API 区域</td>
										<td><input type="text" class="layui-input" asp-for="ApiArea" style="width:100%;" /></td>
										<td></td>
									</tr>
									<tr>
										<td>Api控制器-前缀</td>
										<td><input type="text" class="layui-input" asp-for="ApiControllerEntityPrefix" style="width:100%;" /></td>
										<td></td>
									</tr>
									<tr>
										<td>ApiDto-实体前缀</td>
										<td><input type="text" class="layui-input" asp-for="ApiDtoEntityPrefix" style="width:100%;" /></td>
										<td>包括Input,Out,Query</td>
									</tr>
								</tbody>
							</table>
						</div>
					</div>
				</div>
			</div>
		</div>
	</form>
</div>

@section Scripts{
	<script>
		layui.define(['element', 'jquery', 'form', "button"], function () {
			var $ = layui.jquery
			var form = layui.form;
			var element = layui.element;
			var button = layui.button;

			//提交-保存配置
			form.on('submit(submit)', function (obj) {
		@*$.post("@(Url.Action("UpdateMenuData"))", {}, function (result) {
				abc.success("刷新完成");
				});*@
					abc.post({ url: '@(Url.Action("GenerateCodeEdit"))', data: obj.field, successMsg: "更新数据库中菜单完成" });
				return false;
			});

			//提交生成代码
			form.on('submit(submit_gc)', function (obj) {
		@*$.post("@(Url.Action("RefreshCache"))", {}, function (result) {
				abc.success("刷新缓存完成");
				});*@
					abc.post({ url: '@(Url.Action("SubmitGenerateCode"))', data: obj.field, successMsg: "刷新完成" });
				return false;
			});

		})
	</script>
}
